<%@page import="com.railway.system.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<html>
<head>

	<%@ include file="/commons/commoncssjs.jsp" %>
	<title><%=SysUser.TABLE_ALIAS%>编辑</title>
 		<SCRIPT type="text/javascript">
	   function openURL(urlstr,width,height){  
      	var url ;
      	if('Dept' == urlstr){
       	  url = '${ctx}/system/SysDept/showDeptTree.do';      
      	}     
           var returnVal = window.showModalDialog(url, window, "dialogWidth="+width+"px;dialogHeight="+height+"px;status:0;scroll:no");   
 
           form1.deptId.value = returnVal[0].substring(1);                
           form1.deptname.value = returnVal[1];  
      }  
      </script>
</head>
<body>
	<form id="form1" action="${ctx}/system/SysUser/update.do" method="post">
		<input type="submit" value="提交"  />
		<input type="button" value="返回列表" onclick="window.location='${ctx}/system/SysUser/list.do'"/>
		<input type="button" value="后退" onclick="history.back();"/>
		
		<table class="formTable">
		     <th colspan="2">
                <%=SysUser.TABLE_ALIAS%>编辑</th>
			<input type="hidden" id="id" name="id" value="${model.id}"/>
		 
			<!--<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_USER_ID%>:
				</td>	
				<td>
				<input id="userId" name="userId" value="${model.userId}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			 -->
			 <tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_USER_NAME%>:
				</td>	
				<td>
				<input id="userName" name="userName" value="${model.userName}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_USER_PWD%>:
				</td>	
				<td>
				<input id="userPwd" name="userPwd" value="${model.userPwd}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<!--<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_CARD_TYPE%>:
				</td>	
				<td>
				<input id="cardType" name="cardType" value="${model.cardType}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_CARD_ID%>:
				</td>	
				<td>
				<input id="cardId" name="cardId" value="${model.cardId}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			-->
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_POSITION%>:
				</td>	
				<td>
				<input id="position" name="position" value="${model.position}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			<!--  
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_USER_NO%>:
				</td>	
				<td>
				<input id="userNo" name="userNo" value="${model.userNo}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_COMPANY_ADD%>:
				</td>	
				<td>
				<input id="companyAdd" name="companyAdd" value="${model.companyAdd}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			--><tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_DEPT_NAME%>:
				</td>	
				<td>
				<input id="deptname" name="deptname"value="${model.deptName}" type="text" readonly  class="easyui-validatebox" onclick="javascript:openURL('Dept',300,450)"/>
				<input id="deptId" name="deptId" value="${model.deptId}" type="hidden"  class="easyui-validatebox"   />
				</td>
			 
			</tr>
			
			
			<!--
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_BIRTHDAY%>:
				</td>	
				<td>
				<input value="${model.birthdayString}" id="birthdayString" name="birthdayString"  
				type="text" class="easyui-datebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_EMAIL%>:
				</td>	
				<td>
				<input id="email" name="email" value="${model.email}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			--><tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_PHONE%>:
				</td>	
				<td>
				<input id="phone" name="phone" value="${model.phone}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_MOBILE%>:
				</td>	
				<td>
				<input id="mobile" name="mobile" value="${model.mobile}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr><!--
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_FAMILY_ADDR%>:
				</td>	
				<td>
				<input id="familyAddr" name="familyAddr" value="${model.familyAddr}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_SEX%>:
				</td>	
				<td>
				<input id="sex" name="sex" value="${model.sex}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_FAX%>:
				</td>	
				<td>
				<input id="fax" name="fax" value="${model.fax}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_CREATOR%>:
				</td>	
				<td>
				<input id="creator" name="creator" value="${model.creator}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_CREATE_TIME%>:
				</td>	
				<td>
				<input value="${model.createTimeString}" id="createTimeString" name="createTimeString"  
				type="text" class="easyui-datebox"/>
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_USER_STATUS%>:
				</td>	
				<td>
				<input id="userStatus" name="userStatus" value="${model.userStatus}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_DELETED%>:
				</td>	
				<td>
				<input id="deleted" name="deleted" value="${model.deleted}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_MEMO%>:
				</td>	
				<td>
				<input id="memo" name="memo" value="${model.memo}"
				type="text"  class="easyui-validatebox"   />
				</td>
			</tr>
			
			
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_LAST_LOGIN%>:
				</td>	
				<td>
				<input value="${model.lastLoginString}" id="lastLoginString" name="lastLoginString"  
				type="text" class="easyui-datebox"   />
				</td>
			</tr>
			-->
			<tr>	
				<td class="tdLabel">
					<%=SysUser.ALIAS_AREA_ID%>:
				</td>	
				<td>
				   <input type="checkbox" name="area" value="msg"
				      <c:if test="${fn:indexOf(model.areaId,'msg')>=0}" >
				     checked
				      </c:if>
				    >消息系统 
				   <input type="checkbox" name="area" value="web"
				   <c:if test="${fn:indexOf(model.areaId,'web')>=0}" >
				     checked
				     </c:if>
				    >前台网站 
				   <input type="checkbox" name="area" value="admin"
				   <c:if test="${fn:indexOf(model.areaId,'admin')>=0}" >
				     checked
				     </c:if>
				   >后台管理
			
				</td>
			</tr>
			 <tr>	
				<td class="tdLabel" colspan= 2>
					授权:
				</td>	
				
			</tr>
			<c:forEach items="${requestScope.sysfunc}" var="item">
			<tr>	
				<td  colspan= 2>
					<input type="checkbox"  name="funcs" value="${item.id}" id="cates${item.id}" onClick="checkStatus('${item.id}',this,'cates')"  
					<c:if test="${requestScope.userFuncs!=null&&fn:indexOf(requestScope.userFuncs,item.id)>=0}">
					checked
					</c:if>
					 >${item.funcName}
					
				</td>	
				
			</tr>
			<c:if test="${item.cateList!=null}">
			<tr>	
				<td  colspan= 2>	
				 <c:forEach items="${item.cateList}" var="temp">
			 	  <input type="checkbox"  value="${temp.id}" class="cates${item.id}"  name="cates" id="funcs${temp.id}" onClick="checkCate('${temp.id}',this,'funcs')"  
			 	  <c:if test="${requestScope.userCates!=null&&fn:indexOf(requestScope.userCates,temp.id)>=0}">
					 checked
					</c:if>
			 	   >${temp.names}
				
				</c:forEach>
				</td>	
			 </tr>
					</c:if>
			</c:forEach>
		</table>
	</form>

</body> 
<script>
 function checkStatus(no,chkBox,names){
	 
		 var chks = document.getElementsByTagName('input');//得到所有input
		 for(var i=0;i <chks.length;i++){
			 if(chks[i].name == names){//得到所名为check的input
			     if(chks[i].className == names+no){//ID等于传进父目录ID时
							chks[i].checked = chkBox.checked;//保持选中状态和父目录一致
	                         
					}
			 }
		 }
		 
		 
	 }
 function checkCate(no,chkBox,names){
	     checkPar(chkBox,'cates');//当子目录选中时,父目录也选中
 }
 function checkPar(chkBox,names) {
           if(chkBox.checked==true&&chkBox.className != ''){
               var chkObject = document.getElementById(chkBox.className);
               chkObject.checked=true;
           }else if(chkBox.className != ''){
			 var chkObj=getElementsByClassName(names,chkBox.className);
				  var  res=true;
				  for(var j=0;j<chkObj.length;j++){
				      if(chkObj[j].checked){
				          res=false;
				      } 
				  }
				  if(res){
				      var chkObject = document.getElementById(chkBox.className);
				      chkObject.checked=false;
				  }
		  }
	 }
	 function getElementsByClassName(name,calssName){
		 
			var objArr = document.getElementsByName(name);
			var tRObj = new Array();
			for(var i=0; i<objArr.length; i++){
				if(objArr[i].className ==calssName){
				tRObj.push(objArr[i]);
			}
		}
		return tRObj;
    }
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){
	return $('#form1').form('validate');
});}
)//end $(document).ready(handler)
</script> 
</html>